<%@ page import="java.util.List" %>
<%@ page import="com.jy.bean.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.jy.bean.Consignee" %>
<%@ page import="com.jy.bean.Order" %>
<%@ page import="com.jy.bean.Orderdetail" %><%--
  Created by IntelliJ IDEA.
  User: wave2003
  Date: 2022/6/12
  Time: 9:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="jsBao/jquery-1.11.2.js"></script>
<script src="js/merchant.js"></script>
<style>
    @import "css/merchant.css";
</style>
<body style="margin: auto" onload="Loading_animation(),type_of_erchandise(),scrollback()" onscroll="scroll_bar()">
<div id="tou">
    <div class="loading">
        <span>程序员正在拼命加载中</span>
    </div>
</div>
    <div id="top">
        <div class="row">
            <div class="col-xl-4">
                <div class="col-log">
                    <div class="log"><a href="www.mi.com.jsp"><img width="50px" height="50px" src="img/register/xiaomi.jpg"/></a></div>
                    <div class="log_txt"><samp>小米商城后台</samp></div>
                    <div class="admin">
                        <img src="img/merchant/Admin.png"/>
                    </div>
                    <div class="admin_txt">
                        <samp>${sessionScope.merchant_admin}</samp>
                    </div>
                </div>
                <div class="overflow-hidden">
                    <div class="user" style="width: 1810px;">
                        <div class="user_col">
                            <div class="col-sm-4">
                                <div class="col-md-4">
                                    <div class="col-txt-4">
                                        <samp>今日订单</samp>
                                        <samp>${sessionScope.count}<samp></samp>笔</samp>
                                    </div>
                                    <div class="col-img-4">
                                        <img src="img/merchant/订单详情-订单状态.png"/>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="col-txt-4">
                                        <samp>今日流水</samp>
                                        <samp>${sessionScope.turnover}<samp>￥</samp></samp>
                                    </div>
                                    <div class="col-img-4">
                                        <img src="img/merchant/订单详情-订单状态.png"/>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="col-txt-4">
                                        <samp>商品数量</samp>
                                        <samp>${sessionScope.commodity}<samp>个</samp></samp>
                                    </div>
                                    <div class="col-img-4">
                                        <img src="img/merchant/订单详情-订单状态.png"/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-8">
                                <div class="cx">
                                    <form>
                                    <table border="1px" style="border: 1px white solid;">
                                        <tr>
                                            <td>用户id：</td>
                                            <td><input type="text" id="user_id"></td>
                                            <td>账号：</td>
                                            <td><input type="text" id="user_account"></td>
                                            <td>邮箱：</td>
                                            <td><input type="text" id="user_email"></td>
                                        </tr>
                                        <tr>
                                            <td>注册日期：</td>
                                            <td><input type="text" id="user_data"></td>
                                            <td colspan="4">
                                                &nbsp;<input type="button" value="查询" onclick="doSearch()"/>&nbsp;
                                                <input type="reset" onclick="cx_reset()" value="重置"/>
                                            </td>
                                        </tr>
                                    </table>
                                    </form>
                                </div>
                                <div class="col-sm-user">
                                    <form>
                                    <table id="sm-user" border="1px">
                                        <tr style="background-color: #1296db;">
                                            <td>用户id</td>
                                            <td>账号</td>
                                            <td>邮箱</td>
                                            <td>收货地址</td>
                                            <td>收货人姓名</td>
                                            <td>注册日期</td>
                                            <td>操作</td>
                                        </tr>
                                        <%
                                            List<User> users = (List<User>) session.getAttribute("Listuser");
                                            System.out.println(users);
                                            for (User user:users){
                                                out.println("<tr class='sm-users' id='user_"+user.getId()+"'>");
                                                out.println("<td>"+ user.getId() +"</td>");
                                                out.println("<td>"+ user.getName() +"</td>");
                                                out.println("<td>"+ user.getEmail() +"</td>");
                                                out.println("<td>"+ user.getAddress() +"</td>");
                                                out.println("<td>"+ user.getConsigneeName() +"</td>");
                                                out.println("<td>"+ user.getDatetime() +"</td>");
                                                out.println("<td><input id='"+user.getName()+"' type='button' onclick='Delete_user(id)'  value='删除'>" +
                                                        "<input id='"+user.getName()+"' type='button' onclick='Update_user(id)'  value='修改'></td>");
                                                out.println("</tr>");
                                            }
                                        %>
                                    </table>
                                    </form>
                                </div>
                                <div class="cx" style="margin-left: 180px;margin-bottom: 10px;">
                                        <table border="1px" style="border: 1px white solid;">
                                            <form style="margin-left: 150px;">
                                                <tbody>
                                                    <tr>
                                                        <td>名称：</td>
                                                        <td colspan="3"><input type="text" id="consignee_name" name="consignee_name" style="width: 100%;"></td>
                                                        <td>类型：</td>
                                                        <td><select id="consignee_type" name="consignee_type" style="width: 145px"></select></td>
                                                    </tr>
                                                    <tr>
                                                        <td>价格：</td>
                                                        <td colspan="3"><input type="text" style="width: 100%" id="consignee_price" name="consignee_price"></td>
                                                        <td colspan="4" rowspan="2">
                                                            &nbsp;<input type="button" onclick="Query_the_goods()"  value="查询"/>&nbsp;
                                                            <input type="button" onclick="Modify_the_goods()" value="修改"/>&nbsp;
                                                            <input type="button" onclick="Determine_commodity()" value="添加"/>&nbsp;
                                                            <input type="reset" onclick="cx_reset()" value="重置"/>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </form>
                                        </table>
                                </div>
                                <div>

                                </div>
                                <div class="col-sm-product">
                                    <form>
                                    <table id="sm-product" border="1px">
                                        <tr style="background-color: #1296db;">
                                            <td>商品id</td>
                                            <td>名称</td>
                                            <td>类型</td>
                                            <td>价格</td>
                                            <td>操作</td>
                                        </tr>
                                        <tbody id="commodity">
                                        <%
                                            List<Consignee> consignees = (List<Consignee>) session.getAttribute("Listconsignee");
                                            for (Consignee consignee:consignees){
                                                out.println("<tr>");
                                                out.println("<td>"+ consignee.getId() +"</td>");
                                                out.println("<td>"+ consignee.getName() +"</td>");
                                                out.println("<td>"+ consignee.getType() +"</td>");
                                                out.println("<td>"+ consignee.getPrice() +"</td>");
                                                out.println("<td><input id='"+consignee.getId()+"' type='button' value='操作' onclick='doConsignee(id)'/>" +
                                                        "<input id='"+consignee.getName()+"' type='button' value='删除' onclick='Delete_goods(id)'/></td>");
                                                out.println("</tr>");
                                            }
                                        %>
                                        </tbody>
                                    </table>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-12" style="width: 920px;overflow: scroll;">
                            <table id="sm-order" border="1px">
                                <tr style="background-color: #1296db;">
                                    <td>序号</td>
                                    <td>订单编号</td>
                                    <td>总金额</td>
                                    <td>订单提交时间</td>
                                    <td>收货地址</td>
                                    <td>订单状态</td>
                                    <td>操作</td>
                                </tr>
                                <tbody id="order">
                                    <%
                                        List<Orderdetail> orders = (List<Orderdetail>) session.getAttribute("orderList");
                                        int i = 1;
                                        for (Orderdetail order:orders){
                                            out.println("<tr>");
                                            out.println("<td>"+ i +"</td>");
                                            out.println("<td>"+ order.getOrdernumber() +"</td>");
                                            out.println("<td>"+ order.getAggregate() +"</td>");
                                            out.println("<td>"+ order.getOrderSubmissionTime() +"</td>");
                                            out.println("<td>"+ order.getReceiverAddress() +"</td>");
                                            //order.getState()
//                                            System.out.print(order.getState() +":");
                                            if ("未付款".equals(order.getState()) || "订单失效".equals(order.getState()) || "已签收".equals(order.getState()) ){
//                                                System.out.print("1");
                                                out.println("<td colspan='2'><input style='text-align: center;' disabled='true' type='text' value='"+order.getState()+"'/></td>");
                                            }else {
                                                out.println("<td><select name='"+order.getOrdernumber()+"'><option selected='selected'>"+order.getState()+"</option><option>已发货</option><option>已送达未签收</option></select></td>");
                                                out.println("<td><input id='"+order.getOrdernumber()+"' type='button' onclick="+"amend(id)"+" value='修改'/></td>");
                                                out.println("</tr>");
                                            }
                                            i++;
                                        }
                                    %>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="particulars">

                </div>
            </div>
            <div class="col-xl-8"></div>
        </div>
    </div>
</body>
</html>
